<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>lisence管理</title>
	<link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css" />
	<link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css" />
	<link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css" />
</head>
<body class="wrap-container clearfix">
<div class="column-content-detail padt10" id="tool">
	<div class="search-cont clearfix">
		<div class="operation-btn-cont">
			<button class="layui-btn layui-btn-normal layui-btn-mid " type="button" data-tab-name="lisence添加"  id="roleAddOrEdit" data-name="添加" ><i class="iconfont marr5">&#xe65e;</i>添加</button>
			<button class="layui-btn layui-btn-normal layui-btn-mid deleteBtn"  type="button" data-url="/sysAppModule/delete"><i class="iconfont marr5">&#xe6a3;</i>删除</button>
			<button class="layui-btn layui-btn-normal layui-btn-mid dataSendBtn"  type="button" data-url="/api/baseLisenceManage/send"><i class="iconfont marr5">&#xe652;</i>lisence下发</button>
			<div class="operright cyt-retract-close hideMenu">
				收起筛选<i class="iconfont">&#xe658;</i>
			</div>
			<div class="operright cyt-retract-open showMenu" style="display: none;">
				展开筛选<i class="iconfont">&#xe936;</i>
			</div>
			<div class="triangle-bottom"></div>
			<div class="triangle-top"></div>
		</div>
		<div class="search-details">
			<form class="layui-form" action="">
				<div class="layui-form-item marb5">
					<div class="layui-inline">
						<label class="layui-form-label w75">用户名称：</label>
						<div class="layui-input-inline">
							<input type="text" name="userInfo" id="userInfo" placeholder="请输入用户名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-inline marl8">
						<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="seacherBtn">搜索</button>
						<button class="layui-btn layui-btn-normal" type="reset" >重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="layui-form mart10" id="table-list">
		<table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
	</div>
</div>
<script type="text/html" id="entityBar">
	<@shiro.hasPermission name="sys:paramConfig:edit">
		<a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green"  lay-event="edit">编辑</a>
	    <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green"  lay-event="encord">数据加密</a>
		<a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green"  lay-event="dispense">生成lisence</a>
	</@shiro.hasPermission>
	<@shiro.hasPermission name="sys:paramConfig:del">
		<button class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-red" lay-event="del">删除</button>
	</@shiro.hasPermission>
</script>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['table','page'],function(){
        var table = layui.table,
            page = layui.page;
        dialog = layui.dialog;
        $ = layui.jquery;
        var tableIns = null;
        page.initDict("base_status,ServiceState",function (dictData) {
            page.showDict($("#status"),page.aceeptDictContentList(dictData,"base_status"),"请选择状态");
            page.showDict($("#type"),page.aceeptDictContentList(dictData,"ServiceState"),"请选择状态");
            var url="/sysLisenceManage/page";
            var cols=[
                {type: 'checkbox', fixed: 'left'},
                {type: 'numbers', title: '序号'},
                {field: 'lisence', title: 'lisence',align:'center'},
                {field: 'userInfo', title: '用户信息',align:'center'},
                {field: 'versonNumber', title: '版本信息',align:'center'},
                {field: 'personNum', title: '用户数量',align:'center'},
                {field: 'status', width:100,title: '启用状态',align:'center', sort: true, templet:function(d){
                    if(d.status=="1"){
                        return '<a class="layui-btn layui-btn-warm layui-btn-xs cy-btnbg-normal">'+page.aceeptDictContentName(dictData,"base_status",d.status)+'</a>';
                    }else {
                        return '<a class="layui-btn layui-btn-xs layui-btn-danger cy-btnbg-grey">'+page.aceeptDictContentName(dictData,"base_status",d.status)+'</a>';
                    }
                }},
                {field: 'type', width:100,title: '网络环境',align:'center', sort: true, templet:function(d){
                    if(d.type=="1"){
                        return '<a class="layui-btn layui-btn-warm layui-btn-xs cy-btnbg-normal">'+page.aceeptDictContentName(dictData,"ServiceState",d.type)+'</a>';
                    }else {
                        return '<a class="layui-btn layui-btn-xs layui-btn-danger cy-btnbg-grey">'+page.aceeptDictContentName(dictData,"ServiceState",d.type)+'</a>';
                    }
                }},
                {field: 'downTime', title: '下发时间', align:'center', sort: true, templet:function(d){
                    return new Date(d.createTime).Format("yyyy-MM-dd hh:mm:ss");
                }},
                {title: '操作', templet:'#entityBar',align:"center", fixed: 'right'}
            ];
            tableIns=page.initDate(cols,url);
        });

        //监听行工具事件
        table.on('tool(entityList)', function(obj){
            var layEvent = obj.event,
                data = obj.data;
            if(layEvent === 'edit'){ //编辑
                page.editPopup("/sysLisenceManage/getEdit?id="+data.id,"编辑","1000px","700px");
            }else if(layEvent === 'del'){ //删除
                    page.delete("/sysAppModule/delete", {"id":data.id,"_method":"DELETE"},"确定删除配置吗？",function (data) {
                        top.layer.msg(data);
                    tableIns.reload();
                });
            }else if(layEvent ==='encord'){//数据加密

				//判断lisence是否已经生成
                if(data.lisence ==null||data.lisence ==''){
                    dialog.msg("还没有生成对应的lisence,请先生成对应的lisence");
                    return false;
                }

                page.editlist("/sysVersion/encordVersion",{"id":data.id},"是否根据该lisence对基础数据进行加密",function (data) {
                    top.layer.msg(data);
                    tableIns.reload();
                });
            }else if(layEvent ==='dispense') {//lisence生成
                page.editlist("/sysLisenceManage/encordLisence", {"id": data.id}, "是否对该lisence进行加密", function (data) {
                    top.layer.msg(data);
                    tableIns.reload();
                });
            }
        });

        /**
         * 工具栏-下发
         */
        $('#tool .dataSendBtn').click(function () {
            var url = $(this).attr('data-url');
            var ids = page.checkBoxCheckedIds();
            if (ids != null) {
                page.editlist(url, {"id": ids}, "您确定要下发选中项吗？", function (data) {
                    debugger
                    top.layer.msg(data);
                    tableIns.reload();
                });
            }
            return false;
        });

        $("#roleAddOrEdit").bind("click",function () {
            page.editPopup("/sysLisenceManage/getEdit","lisence添加","1000px","700px");
        });
    });
</script>
</body>
</html>